<script>
	import {
		jgpush
	} from '@/utils/JGPush.js'
	
	export default {
		data(){
			return{}
		},
		onLaunch: function() {
			// #ifdef APP-PLUS
			jgpush()
			setTimeout(() => {
			  plus.navigator.closeSplashscreen();
			}, 3000);
			// this.getClipData()
			// #endif
		},
		onShow() {
			// #ifdef APP-PLUS
			// 跳转传参
			const token = uni.getStorageSync('token');
			if (token) {
				this.getRuntime();
			}
			// #endif
			
			setTimeout(() => {
				// #ifdef APP-PLUS
				plus.navigator.closeSplashscreen();
				// #endif
			},500);
		},
		methods: {
			getClipData() {
				uni.getClipboardData({
					success: (res) => {
						console.log(res.data)
						if (res.data) {
							if(res.data){
								const data = JSON.parse(res.data);
								uni.setStorageSync('shareData', data)
							}
						} else {
							uni.removeStorageSync('shareData')
						}
					},
					fail: () => {
						uni.removeStorageSync('shareData')
					}
				})
				console.log('App Launch');
				const token = uni.getStorageSync('token');
				const boo = uni.getStorageSync('openForFirstTime')
				if (!token && !boo) {
					uni.reLaunch({
						url: '/pages/start/start'
					});
				}else if(!token && boo) {
					uni.reLaunch({
						url: '/pages/login/login'
					});
				}else{
					uni.switchTab({
						url:'/pages/index/index'
					})
				}
			},
			// H5传参
			getRuntime() {
				let args = plus.runtime.arguments;
				// 0话题 1课程 2拼单
				const url = {
					0: '/pages/topic/topicDetail/topicDetail',
					1: '/pages/index/courseItem/courseItem',
					2: '/pages/mine/views/vip/buyVip'
				};
				if (args && args.split('?')[1] !=undefined) {
					console.log(args,args.split('?')[1])
					let data = JSON.parse(args.split('?')[1]);
					const stamp = uni.getStorageSync('stamp');
					if (stamp && stamp == data.stamp) return; // 用时间戳避多次重复跳转
					const token = uni.getStorageSync('token');
					const boo = uni.getStorageSync('openForFirstTime')
					if (!token && !boo) {
						uni.reLaunch({
							url: '/pages/start/start'
						});
						return
					}else if(!token && boo) {
						uni.reLaunch({
							url: '/pages/login/login'
						})
						return
					}
					setTimeout(() => {
						uni.setStorageSync('stamp', data.stamp);
						uni.navigateTo({
							url: `${url[data.objectType]}?id=${data.serviceId}&shareId=${data.shareId}&title=${data.title}`
						});
					}, 200);
				}
			}
		}
	};
</script>

<style lang="scss">
	@import 'https://yzxk.oss-cn-hangzhou.aliyuncs.com/quill/quill.bubble.css';
	@import 'https://yzxk.oss-cn-hangzhou.aliyuncs.com/quill/quill.core.css';
	@import 'https://yzxk.oss-cn-hangzhou.aliyuncs.com/quill/quill.snow.css';
	// 状态栏高度
	/*每个页面公共css */
	@import 'uview-ui/index.scss';

	* {
		margin: 0;
		padding: 0;
	}

	@import url('static/scss/style.scss');
	@import url('static/common/common.css');

	::v-deep .u-tabs__wrapper__nav__line {
		left: 18rpx;
	}

	::v-deep .u-loadmore {
		height: 70rpx !important;

		.u-loadmore__content {
			.u-loadmore__content__text {
				line-height: 70rpx !important;
				font-size: 30rpx !important;
			}
		}

		.u-loading-icon {
			transform: scale(1.5) !important;
		}
	}
	    .uni-tabbar .uni-tabbar-icon {
	      width: 24rpx;
	      height: 24rpx;
	    }
</style>
